/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.gwc.extendsplat.sys.entity;

import com.thinkgem.jeesite.modules.sys.entity.User;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;

import javax.validation.constraints.NotNull;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.Length;

import com.thinkgem.jeesite.common.persistence.DataEntity;

/**
 * 站内信Entity
 * @author 黎俊涛
 * @version 2017-04-13
 */
public class SysSitemessage extends DataEntity<SysSitemessage> {
	
	private static final long serialVersionUID = 1L;
	private User sender;		// 发送人
	private User receiver;		// 接收人
	private String msgTitle;		// 标题
	private String msgContent;		// 内容
	private String isread;		// 读取状态
	private String senderDelFlag;		// 发件人删除标记
	
	public SysSitemessage() {
		super();
	}

	public SysSitemessage(String id){
		super(id);
	}

	public User getSender() {
		return sender;
	}

	public void setSender(User sender) {
		this.sender = sender;
	}
	
	@NotNull(message="接收人不能为空")
	public User getReceiver() {
		return receiver;
	}

	public void setReceiver(User receiver) {
		this.receiver = receiver;
	}
	
	@Length(min=1, max=100, message="标题长度必须介于 1 和 100 之间")
	public String getMsgTitle() {
		return msgTitle;
	}

	public void setMsgTitle(String msgTitle) {
		this.msgTitle = msgTitle;
	}
	
	@Length(min=1, max=1000, message="内容长度必须介于 1 和 1000 之间")
	public String getMsgContent() {
		return msgContent;
	}

	public void setMsgContent(String msgContent) {
		this.msgContent = msgContent;
	}
	
	@Length(min=0, max=1, message="读取状态长度必须介于 0 和 1 之间")
	public String getIsread() {
		return isread;
	}

	public void setIsread(String isread) {
		this.isread = isread;
	}
	
	@Length(min=0, max=1, message="发件人删除标记长度必须介于 0 和 1 之间")
	public String getSenderDelFlag() {
		return senderDelFlag;
	}

	public void setSenderDelFlag(String senderDelFlag) {
		this.senderDelFlag = senderDelFlag;
	}
	@Override
	public void preInsert(){
		User user=UserUtils.getUser();
		if (StringUtils.isNotBlank(user.getId())){
			this.sender=user;
			this.senderDelFlag="0";
			this.isread="0";
		}
		super.preInsert();
	}
}